part of 'header.dart';

class MyWallertView extends StatelessWidget {
  MyWallertView({Key? key}) : super(key: key);
  final controller = Get.find<MeController>();

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.fromLTRB(gap12, 0, gap12, gap10),
      padding: EdgeInsets.fromLTRB(gap12, gap10, gap12, gap20),
      width: Get.width - 2 * gap12,
      decoration: BoxDecoration(
          color: ColorsUtil.white,
          borderRadius: BorderRadius.circular(circle4)),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          TitleContentItemView(title: '我的卡包', content: '进入卡包'),
          SizedBox(
            height: gap10,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: const [
              MyWallertItemView(remain: 6, name: '优惠券'),
              MyWallertItemView(remain: 20, name: '开拓金', unit: '万', iden: '最高'),
              MyWallertItemView(
                  remain: 5, name: '礼品卡', unit: '张', iden: '激活立减'),
              MyWallertItemView(remain: 168, name: '账户余额', unit: '元'),
            ],
          )
        ],
      ),
    );
  }
}

class MyWallertItemView extends StatelessWidget {
  const MyWallertItemView(
      {Key? key,
      required this.remain,
      required this.name,
      this.unit,
      this.iden})
      : super(key: key);
  final num remain;
  final String name;
  final String? unit;
  final String? iden;
  @override
  Widget build(BuildContext context) {
    return InkWell(
      child: Column(
        crossAxisAlignment:
            unit == null ? CrossAxisAlignment.center : CrossAxisAlignment.start,
        children: [
          SizedBox(
            height: 35.w,
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.end,
              children: [
                Text(
                  '$remain',
                  textAlign: TextAlign.end,
                  style: pfSCStyle(color: ColorsUtil.title, fontSize: font20),
                ),
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      height: 16.w,
                      padding: EdgeInsets.symmetric(horizontal: 5.w),
                      decoration: iden == null
                          ? null
                          : BoxDecoration(
                              color: const Color(0xfff24e4e),
                              borderRadius: BorderRadius.circular(8.w)),
                      child: Text(
                        iden ?? '',
                        style: pfSCStyle(
                            color: ColorsUtil.white, fontSize: font11),
                      ),
                    ),
                    Visibility(
                        visible: unit != null,
                        child: Text(
                          unit ?? '',
                          style: pfSCStyle(
                              color: ColorsUtil.title, fontSize: font11),
                        ))
                  ],
                )
              ],
            ),
          ),
          Text(
            name,
            style: pfMediumStyle(color: ColorsUtil.title, fontSize: font13),
          )
        ],
      ),
    );
  }
}
